import { SkillModel } from '../../models/Skill'

export default defineEventHandler(async (event) => {
  try {
    const { id } = getRouterParams(event)
    
    if (!id) {
      return {
        success: false,
        message: '技能ID不能为空',
        data: null
      }
    }
    
    const success = await SkillModel.deleteSkill(parseInt(id))
    
    if (!success) {
      return {
        success: false,
        message: '技能不存在或删除失败',
        data: null
      }
    }
    
    return {
      success: true,
      message: '删除技能成功',
      data: { id: parseInt(id) }
    }
  } catch (error: any) {
    console.error('删除技能失败:', error)
    
    return {
      success: false,
      message: `删除技能失败: ${error.message}`,
      data: null
    }
  }
})